package com.cao.service;

import com.cao.dao.BookMapper;
import com.cao.pojo.Books;
import com.cao.pojo.Category;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;



public class BookServiceImpl implements BookService {

    //service层调dao层
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    public int save(Books books) {
        return bookMapper.save(books);
    }

    public int delBookById(Integer id) {
        return bookMapper.delBookById(id);
    }

    public Books queryBookById(Integer id) {
        return bookMapper.queryBookById(id);
    }

    public List<Books> queryBookList() {
        return bookMapper.queryBookList();
    }

    public int updateBook(Books books) {
        return bookMapper.updateBook(books);
    }

    public List<Books> queryBookByName(String bookName,Integer selectCategory) {
        if (selectCategory ==0){
            selectCategory=null;
        }
        return bookMapper.queryBookByName(bookName,selectCategory);
    }

    @Override
    public List<Category> queryBookCategory() {
        return bookMapper.queryBookCategory();
    }
}
